<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点击后5秒不可点击</title>
    <script src="../js/vue.js"></script>
    <style>

    </style>
</head>
<body>
    <div id="main">
        <button :disabled=state>倒计时{{num}}秒</button><button @click="start">开始计时</button>
    </div>

    <script>
        let app = new Vue({
            el:"#main",
            data:{
                num:10,
                state:false
            },
            methods:{
                start(){
                    let timer = null;
                    console.log("点击了start事件");
                    this.state = true
                    timer = setInterval(() => {
                        if(this.num == 0){
                            this.num = 10
                            this.state = false
                            clearInterval(timer)
                        }else{
                            this.num -- 
                        }
                    }, 1000);
                }
            }
        })
    </script>
</body>
</html>